/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TelaGerenciaAeroporto.java
 *
 * Created on Jul 22, 2010, 2:45:46 AM
 */

package telas;
import controladoras.apresentacao.CntrIntAeroporto;
import controladoras.apresentacao.modelos.ModeloTabelaAeroporto;
/**
 *
 * @author thiagostuckert
 */
public class TelaGerenciaAeroporto extends javax.swing.JFrame {

    /** Creates new form TelaGerenciaAeroporto */
    public TelaGerenciaAeroporto() {
        initComponents();
    }
    
    private static TelaGerenciaAeroporto ref;
    public static TelaGerenciaAeroporto instanciar() {
        if(ref == null)
            ref = new TelaGerenciaAeroporto();
        return ref;
    }
    
    private CntrIntAeroporto cntrIntAeroporto;

    public void setControladoraInteracao(CntrIntAeroporto cntr){
        cntrIntAeroporto = cntr;
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        fechar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        Aeroporto = new javax.swing.JTextField();
        Cidade = new javax.swing.JTextField();
        AdicionarAeroporto = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabelaAeroporto = new javax.swing.JTable();
        RemoverAeroporto = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        fechar.setText("Fechar");
        fechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fecharActionPerformed(evt);
            }
        });

        jLabel1.setText("Tela de Gerência de Aeroporto");

        Aeroporto.setText("Aeroporto a ser Adicionado");

        Cidade.setText("Cidade do Aeroporto");

        AdicionarAeroporto.setText("Adicionar Aeroporto");
        AdicionarAeroporto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AdicionarAeroportoActionPerformed(evt);
            }
        });

        tabelaAeroporto.setModel(ModeloTabelaAeroporto.instanciar());
        jScrollPane1.setViewportView(tabelaAeroporto);

        RemoverAeroporto.setText("Deleta Aeroporto");
        RemoverAeroporto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RemoverAeroportoActionPerformed(evt);
            }
        });

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jTextArea1.setText("Para editar um aeroporto, clique sobre\neste na lista ao lado, edite  e aperte\nenter.");
        jScrollPane2.setViewportView(jTextArea1);

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(157, 157, 157)
                        .add(jLabel1))
                    .add(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(Cidade, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(Aeroporto, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(RemoverAeroporto)
                            .add(jPanel1Layout.createSequentialGroup()
                                .add(74, 74, 74)
                                .add(AdicionarAeroporto))
                            .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(226, 226, 226)
                        .add(fechar)))
                .addContainerGap(152, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel1)
                .add(26, 26, 26)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 258, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(RemoverAeroporto)
                        .add(32, 32, 32)
                        .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .add(15, 15, 15)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(Aeroporto, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(AdicionarAeroporto))
                .add(18, 18, 18)
                .add(Cidade, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 26, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(5, 5, 5)
                .add(fechar)
                .addContainerGap())
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void fecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fecharActionPerformed
        cntrIntAeroporto.encerrar();
}//GEN-LAST:event_fecharActionPerformed

    private void AdicionarAeroportoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AdicionarAeroportoActionPerformed
        // TODO add your handling code here:
        cntrIntAeroporto.addAeroporto(Aeroporto.getText(), Cidade.getText());
    }//GEN-LAST:event_AdicionarAeroportoActionPerformed

    private void RemoverAeroportoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RemoverAeroportoActionPerformed
        // TODO add your handling code here:
        cntrIntAeroporto.delAeroporto(tabelaAeroporto.getSelectedRow());
    }//GEN-LAST:event_RemoverAeroportoActionPerformed

    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AdicionarAeroporto;
    private javax.swing.JTextField Aeroporto;
    private javax.swing.JTextField Cidade;
    private javax.swing.JButton RemoverAeroporto;
    private javax.swing.JButton fechar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTable tabelaAeroporto;
    // End of variables declaration//GEN-END:variables

}
